package beusoft.ccjk.com.calculator.sort;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Stack;

/**
 * Created by CCJK on 2017/12/15.
 * 汉诺塔问题
 */

public class Hanoi {
    private int mDiskCount = 3;
    private List<Integer> mA = new ArrayList<>();
    private List<Integer> mB = new ArrayList<>();
    private List<Integer> mC = new ArrayList<>();

    private Map<String, List<Integer>> map = new HashMap<>();

    public Hanoi(int mDiskCount) {
        this.mDiskCount = mDiskCount;
        map.put("A", mA);
        map.put("B", mB);
        map.put("C", mC);
    }

    public void start() {
        mA.clear();
        mB.clear();
        mC.clear();
        for (int i = 1; i <= mDiskCount; i++) {
            mA.add(i);
        }
        step(mDiskCount, "A", "B", "C");
    }


    private void step(int count, String from, String middle, String to) {
        dumps();
        if (count == 1) {
            println("Disk 1 from" + from + " to " + to);
        } else {
            step(count - 1, from, to, middle);
            println("Disk " + count + " from " + from + " to " + to);
            step(count - 1, middle, from, to);
        }

    }

    private void dumps() {
        println("/////////////////////////////////////////////////////////");
        print(mA);
        print(mB);
        print(mC);
    }

    private void println(Object o) {
        System.out.println(o);
    }

    private void print(Object o) {
        System.out.print(o);
    }


}
